package com.nmsl.controller;
import com.nmsl.domain.GyfEmployee;
import com.nmsl.mapper.GyfEmployeeMapper;
import com.nmsl.util.R.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Date;
import java.util.List;

@RequestMapping("/em")
@RestController
public class gyf_EmployeeController {
    @Autowired
    private GyfEmployeeMapper employeeMapper;

    //通过部门id和日期来查询当天的医生
    @GetMapping("/select")
    public R select(int departmentId, Date scheduledata){
        List<GyfEmployee> select = employeeMapper.select(departmentId, scheduledata);
        if(select.size() > 0){
            return R.ok(select);
        }else{
            System.out.println(select);
            System.out.println("没有找到任何数据");
            return R.fail("没有找到任何数据");
        }


    }

    //通过医生id和日期查询当天医生的 工作明细时间
    @GetMapping("/selectTimeByidAndDate")
    public R selectTimeByidAndDate(int employeeId, Date date){
        System.out.println("打印一下传来的参数");
        System.out.println(employeeId);
        System.out.println(date);
        GyfEmployee employee = employeeMapper.selectTimeByidAndDate(employeeId, date);
        if(employee != null){
            return R.ok(employee);
        }else{
            return R.fail("没有找到任何数据");
        }
    }

    //通过医生id  查询医生的信息  以及医生所有的排班表
    @GetMapping("/selectByid")
    public R selectByid(int employeeId){
        List<GyfEmployee> employees = employeeMapper.selectByEmployeeId(employeeId);
        if(employees.size() > 0){
            return R.ok(employees);
        }else{
            return R.fail("没有查到任何信息");
        }
    }

    //通过医生id  查询医生的姓名和职位
    @GetMapping("/selectNameAndJobById")
    public R selectNameAndJobById(int employeeId){
        System.out.println("打印一下教师接口的参数");
        System.out.println(employeeId);
        GyfEmployee gyfEmployee = employeeMapper.selectNameAndJobById(employeeId);
        if(gyfEmployee != null){
            return R.ok(gyfEmployee);
        }else{
            return R.fail("没有查到任何信息");
        }
    }


}
